FROM php:8.1-fpm AS fy_php_fpm
WORKDIR "/www"

RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
    && sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
    && apt-get clean \
    && apt-get update \
    && apt-get -y --no-install-recommends install libzip-dev  \
    && curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/5.3.4.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mkdir -p /usr/src/php/ext \
    && mv phpredis-5.3.4 /usr/src/php/ext/redis \
    && docker-php-ext-install redis \
    && docker-php-ext-install zip \
    && docker-php-ext-install bcmath \
    && docker-php-ext-install pdo_mysql \
    && apt-get clean && apt-get autoremove \
    && rm -rf /var/lib/apt/lists/* \
    && php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && rm composer-setup.php \
    && mv composer.phar /usr/local/bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
    # && echo "#!/bin/bash" > /tmp/init.sh \
    # && echo "cd /www/admin-server" >> /tmp/init.sh \
    # && echo "composer install" >> /tmp/init.sh \
    # && echo "php artisan key:generate" >> /tmp/init.sh \
    # && echo "php artisan storage:link" >> /tmp/init.sh \
    # && echo "php artisan jwt:secret" >> /tmp/init.sh \
    # && chmod +x /tmp/init.sh

# CMD [ "/tmp/init.sh" ]